cmake_minimum_required(VERSION 2.6)
project(lapr C)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")

find_package(Lua51 REQUIRED)
find_package(APR REQUIRED)
find_package(APRUtils REQUIRED)
include_directories(${LUA_INCLUDE_DIR} ${APR_INCLUDE_DIR} ${APRUtils_INCLUDE_DIR})

add_definitions(-D_LARGEFILE64_SOURCE=1)
if(UNIX)
    if(CMAKE_COMPILER_IS_GNUCC)
        add_definitions(-g -Wall)
    endif(CMAKE_COMPILER_IS_GNUCC)
endif(UNIX)

add_library(apr SHARED db_raw.c hash.c socket_raw.c uri.c uuid.c)
SET_TARGET_PROPERTIES(apr PROPERTIES PREFIX "")
target_link_libraries(apr apr-1 aprutil-1)

install(TARGETS apr DESTINATION .)
install(DIRECTORY lua/ DESTINATION apr PATTERN ".svn" EXCLUDE PATTERN "lua/*")
